﻿Imports System.Web.UI
Imports SISSAT.Administration.Views
Imports SISSAT.BusinessLayer.DomainModels

Namespace Pages.Administration
    Public Class Courses
        Inherits Page
        Implements ICourseView

#Region "Properties"

        Private Property Presenter As CoursePresenter

#End Region

#Region "ICourseView Members"

        Public ReadOnly Property CourseId As Integer Implements ICourseView.CourseId
            Get
                Dim id As Integer = 0
                Dim cid As String = HttpContext.Current.Request.QueryString("cid")
                If Not String.IsNullOrEmpty(cid) AndAlso Integer.TryParse(cid, id) Then
                    ' No logic
                ElseIf String.Compare(cid, "new", True) = 0 Then
                    id = 1
                End If

                Return id
            End Get
        End Property

        Public WriteOnly Property RepeaterDataSource As IEnumerable(Of Course) Implements ICourseView.RepeaterDataSource
            Set(value As IEnumerable(Of Course))
                CourseRepeater.DataSource = value
                CourseRepeater.DataBind()
            End Set
        End Property

        Public Event OnInitialization() Implements ICourseView.OnInitialization

#End Region

#Region "Events"

        Private Sub PageInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            If Me.CourseId > 0 Then
                CourseViews.ActiveViewIndex = 1
            End If

            Presenter = New CoursePresenter(Me)
            RaiseEvent OnInitialization()
        End Sub

#End Region

    End Class
End Namespace
